package com.loyin.tool;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpSession;

import com.igs.parse.query.QueryCountUtil;
import com.loyin.model.DownloadUrl;
import com.loyin.model.UserInfoVo;

public class IndexDataUtil
{
	private int todayDownLoadCount = 0;

	private List<DownloadUrl> dlurlList;

	public int getTodayDownLoadCount(HttpSession  session)
	{
		UserInfoVo userinfovo = (UserInfoVo) session.getAttribute("user_session");
		String userid=String.valueOf(userinfovo.getId());
		return QueryCountUtil.getTodayDownLoadCount(userid);
	}

	public void setTodayDownLoadCount(int todayDownLoadCount)
	{
		this.todayDownLoadCount = todayDownLoadCount;
	}

	public List<DownloadUrl> getDlurlList(HttpSession  session)
	{
		try
		{
			UserInfoVo userinfovo = (UserInfoVo) session.getAttribute("user_session");
			String userid=String.valueOf(userinfovo.getId());
		    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");//转换格式 
		    String todayStr = sdf.format(new Date());
			String querySql=" SELECT * FROM igs_downloadurl "
							+" where userid="+userid+" "
							+" and recordtime like '"+todayStr+"%' "
							;
			DownloadUrl msginfo=new DownloadUrl();
			List<DownloadUrl> list = (List<DownloadUrl>) msginfo.findBySql(DownloadUrl.class, querySql);
			return list;
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
			return null;
		}
	}

	public void setDlurlList(List<DownloadUrl> dlurlList)
	{
		this.dlurlList = dlurlList;
	}
	
	
	
	
}
